<?php

namespace common\logics;

use Yii;
use common\helpers\ArrayHelper;

/**
 * H5前端路由模型
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class RouterLogic extends \common\base\Model {

    const SEPARATOR_H5 = '/#/';

    public static function frontend() {
        $frontDomain = ArrayHelper::getValue(Yii::$app->params, 'domain.h5');
        $domain = rtrim($frontDomain, self::SEPARATOR_H5);
        $routes = [
            'home' => 'home',
            'signin' => 'signin',
            'task' => 'task',
            'cart' => 'cart',
            'goods' => 'goods/',
            'address' => 'user/address',
            'notice' => 'notice',
            'help' => 'help',
            'rank' => 'rank',
            'license' => 'page/license',
            'privacy_policy' => 'page/privacy_policy',
            'order_all' => 'order/list/all',
            'order_payment' => 'order/list/payment',
            'order_receive' => 'order/list/receive',
            'order_evaluate' => 'order/list/evaluate',
            'credit' => 'credit/log',
            'experience' => 'experience/log',
            'gold' => 'gold/log',
            'title' => 'title',
            'gift' => 'gift',
            'title' => 'title',
            'exmall' => 'exmall',
            'coupon' => 'coupon',
            'vip' => 'vip',
            'authent' => 'authent',
            'service' => 'service',
            'medal' => 'medal',
            'marking' => 'marking',
            'feedback' => 'feedback',
        ];
        foreach ($routes as $name => $path) {
            $routes[$name] = $domain . self::SEPARATOR_H5 . ltrim($path, '/');
        }
        return compact('domain', 'routes');
    }

}
